package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.MemberLogoVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.MemberUpdateRegisterDetailVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.MemberRegisterDetailVO;
import com.ssy.lingxi.member.merchant.model.vo.manage.request.MemberAndRoleIdVO;
import com.ssy.lingxi.member.merchant.model.vo.manage.response.UpperChannelVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberMainPageService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**@menu “首页”相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-01-23
 */
@RestController
@RequestMapping("/member/mainpage")
public class MemberMainPageController {

    @Resource
    private IMemberMainPageService memberMainPageService;

    /**
     * 新增或修改会员Logo
     * @param headers Http头部信息
     * @param logoVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/logo/add", method = RequestMethod.POST)
    public Wrapper<Void> addMemberUserLogo(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLogoVO logoVO) {
        return memberMainPageService.addMemberUserLogo(headers, logoVO);
    }

    /**
     * “首页” - 审核不通过时，查询会员注册资料信息
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/get", method = RequestMethod.GET)
    public Wrapper<MemberRegisterDetailVO> getMemberRegisterDetail(@RequestHeader HttpHeaders headers) {
        return memberMainPageService.getMemberRegisterDetail(headers);
    }

    /**
     * “首页” - 审核不通过时，修改会员注册资料
     * @param headers Http头部信息
     * @param detailVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberRegisterDetail(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUpdateRegisterDetailVO detailVO) {
        return memberMainPageService.updateMemberRegisterDetail(headers, detailVO);
    }

    /**
     * 查询当前会员渠道角色、及上级渠道会员列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/channel/upper/list", method = RequestMethod.GET)
    public Wrapper<List<UpperChannelVO>> findUpperChannels(@RequestHeader HttpHeaders headers) {
        return memberMainPageService.findUpperChannels(headers);
    }

    /**
     * 判断当前登录会员，是否指定会员的上级会员
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/upper/inquiry", method = RequestMethod.GET)
    public Wrapper<Boolean> isUpperMember(@RequestHeader HttpHeaders headers, @Valid MemberAndRoleIdVO idVO) {
        return memberMainPageService.isUpperMember(headers, idVO);
    }
}
